package com.iemes.controller.mould;

import java.util.List;
import java.util.Map;

import javax.inject.Inject;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.iemes.controller.index.BaseController;
import com.iemes.entity.DevelopProgressFormMap;
import com.iemes.entity.MouldUnpassHandleFormMap;
import com.iemes.entity.PAfterCheckFormMap;
import com.iemes.entity.SurfaceCheckFormMap;
import com.iemes.entity.UserFormMap;
import com.iemes.mapper.mould.DevelopProgressMapper;
import com.iemes.mapper.mould.SurfaceCheckMapper;
import com.iemes.plugin.PageView;
import com.iemes.util.Common;

@Controller
@RequestMapping("/surfaceCheck/")
public class SurfaceCheckController extends BaseController {

	@Inject
	private SurfaceCheckMapper surfaceCheckMapper;
	
	@Inject
	private DevelopProgressMapper developProgressMapper;
	
	@RequestMapping("surfaceCheck_list")
	public String listUI(Model model) throws Exception {
		model.addAttribute("res", findByRes());
		return Common.BACKGROUND_PATH + "/mould/surfaceCheck/surfaceCheck_list";
	}
	
	@ResponseBody
	@RequestMapping("surfaceCheck_findByPage")
	public PageView findByPage(String pageNow, String pageSize) throws Exception 
	{
		DevelopProgressFormMap developProgressFormMap=getFormMap(DevelopProgressFormMap.class);
		List<Map<String, Object>> developProgress = developProgressMapper.getAll(developProgressFormMap);
		LuogicPaging(pageNow, pageSize, developProgress);
		return pageView;
	}
	
	@RequestMapping("surfaceCheck_edit")
	public String editUI(Model model) throws Exception {
		String id = getPara("id");
		if(Common.isNotEmpty(id)){
			//根据id查询模具制造外观质量验收单
			DevelopProgressFormMap progress=developProgressMapper.getById(id);
			model.addAttribute("progress",progress);
			//获得相同developProgressId的检查标准
			SurfaceCheckFormMap surfaceCheckFormMap=new SurfaceCheckFormMap();
			surfaceCheckFormMap.put("developProgressId", progress.get("id"));
			List<SurfaceCheckFormMap> check=surfaceCheckMapper.getSurfaceCheck(surfaceCheckFormMap);
			model.addAttribute("check",check);
		}
		return Common.BACKGROUND_PATH + "/mould/surfaceCheck/surfaceCheck_edit";
	}
}










